//package com.orhon.smartcampus.modules.student.fetcher;
//
//import com.orhon.smartcampus.auth.JwtUtils;
//import com.orhon.smartcampus.modules.user.dao.TokenService;
//import com.orhon.smartcampus.utils.R;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
//import com.orhon.smartcampus.modules.base.entity.Schools;
//import com.orhon.smartcampus.modules.base.gqlModel.GQLSchool;
//import com.orhon.smartcampus.modules.base.mm.SchoolMapper;
//import com.orhon.smartcampus.modules.student.dao.SInformationDao;
//import com.orhon.smartcampus.modules.student.entity.SInformation;
//import com.orhon.smartcampus.modules.student.gqlModel.GQLStudent;
//import com.orhon.smartcampus.modules.student.mm.StudentMapper;
//import com.orhon.smartcampus.modules.user.entity.Users;
//import com.orhon.smartcampus.modules.user.gqlModel.GQLUser;
//import com.orhon.smartcampus.modules.user.mm.UserMapper;
//
//import graphql.schema.DataFetcher;
//import graphql.schema.DataFetchingEnvironment;
//
//@Component
//public class StudentFetcher implements DataFetcher  { 
//
//	@Autowired
//	SInformationDao sInformationDao;
//
//	@Autowired
//	TokenService tokenService;
//
//	@Override
//	public Object get(DataFetchingEnvironment env) throws Exception {
//		String token = tokenService.getSystemToken();
//		if(token==null) {
//			return  R.NoLogin();
//		}
//		Long schoolId = JwtUtils.getSchoolId(token);
//
//		int id = Integer.parseInt(env.getArgument("id").toString());
//		String hql = "from SInformation where deleted_at = null and id = "+id+" and school_id = " + schoolId;
//		SInformation sInformation = sInformationDao.findId(hql, null);
//		if(sInformation!=null) {
//			GQLUser gqlUser = null;
//			if (env.getSelectionSet().contains("data/user")){
//				Users user = sInformation.getUser();
//				gqlUser = UserMapper.MAPPER.mapUser(user);
//			}
//
//			GQLSchool gqlSchool = null;
//			if (env.getSelectionSet().contains("data/school")){
//				Schools school = sInformation.getSchool();
//				gqlSchool = SchoolMapper.MAPPER.toSchool(school);
//			}
//			GQLStudent student = StudentMapper.MAPPER.toStudent(sInformation);
//			student.setUser(gqlUser);
//			student.setSchool(gqlSchool);
//			return student;
//		}
//		return null;
//
//	}}
